<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<link rel="stylesheet" type="text/css" href="/css/css.css" />
	<script src="/js/public.js"></script>
	<script src="/js/jquery.min.js"></script>	
	<title>鹤庭净水</title>
	<style type="text/css">
	</style>
</head>
<body>
	<section class="textPart">
		<P style="padding-top: 2rem;" >请输入16位设备编码</P>
		<input class="codeNumBox" type="number" oninput="maFn();" />
	</section>
	<section class="deviceBindBtn">确定</section>
	<section class="bindBtn" onclick="javacript:history.go(-1)">返回上一步</section>
	<!-- 提交信息服务器反馈信息 -->
	<section class="hint_bg">
		<section class="hint_box">
			<p class="hint_text"></p>
			<section class="hint_btn">确定</section>
		</section>
	</section>
	<script>

		window.onload=function(){
			$('body').height($(window).height());
			$(".deviceBindBtn").click(function(){
				
				if($(".codeNumBox").val().length==16){
					$.ajax({
				    	url:"/api/device/bind",
				    	type:"post",
				    	data:{device_code:$(".codeNumBox").val()},
				    	dataType:'json',
				    	success:function(data){
				    		if(data.status.errCode == 0||data.status.errCode == 20002){
		    					setTimeout(function(){
		    						window.location.href = "/index?"+new Date().getTime();
		    					},300);
				    		}else{					    			
				    			hint(data.status.message);
				    		}
				    	},
				    	error:function(jqXHR, textStatus, errorThrown){
		    				hint("绑定失败" + jqXHR.status + textStatus + errorThrown);
				    	}
				    });
				}else if($(".codeNumBox").val().length>16){
					hint("输入编码超过16位数，重新输入！");
				}
			});
		}
		function maFn(){
		if($(".codeNumBox").val().length==16){
			$(".codeNumBox").blur();
		}else if($(".codeNumBox").val().length>16){
			hint("输入编码超过16位数，重新输入！");
		}
	}
	</script>
</body>
</html>